$(document).ready(function(){
	$('#notification').hide();
	$('.button').click(function (e) {
		// custom handling here
		//e.preventDefault();
	//var state = $('#state').val();
	//alert(checkStatus);
	
	//return false;
		
	var val_form = validateForm();
	
	
	if (val_form == false){
		return false;
	} else {
		$('#register_form').submit();
	}
	
	function testalert() {
		alert('test');
	}

	function validateForm() {
		
		if($('#email').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
				$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Email</span> is required for registration!");
				$('#email').focus();
				return false;
			}
		else 
			{
				var email = $('#email').val();
				//alert(email);
				
				var emailRegex = new RegExp(/^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$/i);
				var valid = emailRegex.test(email);
				if (!valid) {
					$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
					$('#error-msg').html("<span class=\"fontBold\">Email</span> is not valid!");
					return false;
				} 
			}
		
		if($('#urlname').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">URL name</span> is required for registration!");
				$('#urlname').focus();
				return false;
			}
		if($('#password').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Password</span> is required for registration!");
				$('#password').focus();
				return false;
			}
		if($('#confirm_password').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("Please confirm Password!");
				$('#confirm_password').focus();
				return false;
			}
		

		
		/*var password = $('#password').val();
		var c_password = $('#confirm_password').val();
		if (c_password != password){
			$('.frm_checkpwd').show("slide",{direction: 'down'});
			$('.frm_checkpwd').delay(2000).hide("slide",{direction: 'up'});
			$('.frm_checkpwd-msg').removeClass("check_pass").addClass("check_error").text("Password Not Matched");
			$('#confirm_password').focus();
		
			return false;
		} else {
			$('.frm_checkpwd').show("slide",{direction: 'down'});
			$('.frm_checkpwd').delay(2000).hide("slide",{direction: 'up'});
			$('.frm_checkpwd-msg').removeClass("check_error").addClass("check_pass").text("Password Matched");
		}*/
		
		if($('#fullname').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Full name</span> is required for registration!");
				$('#fullname').focus();
				return false;
			}
		if($('#ic_no').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">I/C No</span> is required for registration!");
				$('#ic_no').focus();
				return false;
			}
		if($('#state').val()=='none')
			{
				$('#notification').show("slide",{direction: 'down'});
				$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">State</span> is required for registration!");
				$('#state').focus();
				return false;
			}
		if($('#country').val()=='none')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Country</span> is required for registration!");
				$('#country').focus();
				return false;
			}
		if($('#address1').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Address</span> is required for registration!");
				$('#address1').focus();
				return false;
			}
		if($('#postcode').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Address</span> is required for registration!");
				$('#postcode').focus();
				return false;
			}	
		if($('#phone_no').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
					$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Phone No</span> is required for registration!");
				$('#phone_no').focus();
				return false;
			}
		if($('#mobile_no').val()=='')
			{
				$('#notification').show("slide",{direction: 'down'});
				$('#notification').delay(2000).hide("slide",{direction: 'up'});
				$('#error-msg').html("<span class=\"fontBold\">Mobile No</span> is required for registration!");
				$('#mobile_no').focus();
				return false;
			}
		
		return true; // condition if everything valids
	} // function validateForm ends
	}); // func click button ends
}); // document ready end

